import axios from "axios";
import { ElMessage } from "element-plus";

const service = axios.create({
  baseURL: 'http://49.235.128.49:5059/api/',
  timeout: 50000,
})

service.interceptors.request.use(config => {
  return config
})

service.interceptors.response.use(response => {
  const { code, msg } = response.data

  if (code !== 20000) {
    ElMessage({
      message: msg || '',
      type: 'warning',
      duration: 1000
    })
  }
  return response
}, err => {
  return Promise.reject(err)
})

export default service